package com.carbon.carbonmanager.controller;

import com.carbon.carbonmanager.model.EnterpressInfo;
import com.carbon.carbonmanager.service.EnterpressService;
import com.carbon.carbonmanager.unit.Pager;
import com.carbon.carbonmanager.unit.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 企业开户管理模块API
 * */
@RestController
@CrossOrigin
public class EnterpressController {
    @Autowired
    EnterpressService enterpressService;

    /**
     * 查询所有企业所属行业分类API
     * */
    @ResponseBody
    @RequestMapping(value = "/getAllIndustry", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getAllIndustry(){
        return enterpressService.getAllIndustry();
    }

    /**
     * 添加企业信息用户开户申请
     * API接口
     * */
    @ResponseBody
    @RequestMapping(value = "/ApplyAccount", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response ApplyAccount(@RequestBody EnterpressInfo enterpressInfo){
        return enterpressService.ApplyAccount(enterpressInfo);
    }

    /**
     * 验证用户开户状态，如果已开户则返回的是企业信息数据，如果加载失败则返回的是用户状态
     * */
    @ResponseBody
    @RequestMapping(value = "/validateApplyAccount", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response validateApplyAccount(@RequestBody EnterpressInfo enterpressInfo){
        return enterpressService.validateApplyAccount(enterpressInfo);
    }

    /**
     * 获取开户申请中的企业信息数据列表
     * */
    @ResponseBody
    @RequestMapping(value = "/getApplyingEnterpriseDataMapper", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getApplyingEnterpriseDataMapper(@RequestBody Pager pager){
        return enterpressService.getApplyingEnterpriseDataMapper(pager);
    }

    /**
     * 审核开户状态，设置开户
     * */
    @ResponseBody
    @RequestMapping(value = "/CheckAccount", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response CheckAccount(@RequestBody EnterpressInfo enterpressInfo){
        return enterpressService.CheckAccount(enterpressInfo);
    }

    /**
     * 获取碳资产信息及企业交易数据API接口
     * */
    @ResponseBody
    @RequestMapping(value = "/getEnterprisePropertyDataAndTradeData", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getEnterprisePropertyDataAndTradeData(@RequestBody EnterpressInfo enterpressInfo){
        return enterpressService.getEnterprisePropertyDataAndTradeData(enterpressInfo);
    }
}
